package com.jbm.jbmsupplier;

import java.util.ArrayList;

import com.jbm.jbmsupplier.ui.UserLoginActivity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.ImageView;

public class MainActivity extends Activity  implements OnPageChangeListener{
	private ViewPager viewPager;
	private ViewPagerAdapter vpAdapter;
	private ArrayList<View> views;
	private View cover1View,cover2View,cover3View;
	private ImageView loginButton;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_main);
		
		LayoutInflater mLi = LayoutInflater.from(this);
		this.cover1View = mLi.inflate(R.layout.page_cover1, null);
		this.cover2View = mLi.inflate(R.layout.page_cover2, null);
		this.cover3View = mLi.inflate(R.layout.page_cover3, null);
		
		this.views = new ArrayList<View>();
		this.views.add(cover1View);
		this.views.add(cover2View);
		this.views.add(cover3View);

		this.viewPager = (ViewPager) findViewById(R.id.viewpager);
		this.vpAdapter = new ViewPagerAdapter(this.views);
		this.viewPager.setOnPageChangeListener(this);
		this.viewPager.setAdapter(vpAdapter);

		this.loginButton = (ImageView)this.cover3View.findViewById(R.id.cover_loginButton);
		this.loginButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                     loginButton();
            }

		});
	}
	
	protected void loginButton() {
		Intent newIntent = new Intent(this,UserLoginActivity.class);
		startActivity(newIntent);
		finish();
		
	}

	@Override
	public void onPageScrollStateChanged(int arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onPageScrolled(int arg0, float arg1, int arg2) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onPageSelected(int arg0) {
		// TODO Auto-generated method stub
		
	}
}
